package edu.zut.controller;

import edu.zut.pojo.Employee;
import edu.zut.service.EmpService;
import edu.zut.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "EmpShowServlet", value = "/emp/show")
public class EmpShowServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取查询的参数
        String emp_name = request.getParameter("emp_name");
        System.out.println("emp_name = " + emp_name);
        //将信息查询后动态的返回home.jsp
        EmpService service = new EmpServiceImpl();
        List<Employee> list = service.showEmp(emp_name);
        //动态显示数据
        request.setAttribute("list",list);
        request.getRequestDispatcher("/view/home.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
